package com.ll.enum_;

/**
 * @author 刘龙
 * @version 1.0
 */
public class Enumeration01 {
    public static void main(String[] args) {
        // 对于季节,对象的值是具体的,是固定的四个,不会有更多
        System.out.println(Season.SPRING);

    }
}

/**
 * 自定义枚举类
 */
class Season {
    private String name;
    private String desc;

    /**
     * 定义了4个对象
     */
    public static final Season SPRING = new Season("春天", "温暖");
    public static final Season WINTER = new Season("冬天", "寒冷");
    public static final Season SUMMER = new Season("夏天", "炎热");
    public static final Season AUTUMN = new Season("秋天", "凉爽");

    /**
     * 1.将构造器私有化
     * 2.去掉setXxx方法,防止属性被修改
     * 3.在Season内部,直接创建固定的对象
     * 4.优化,加入final修饰符
     * @param name
     * @param desc
     */
    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}
